import axios from '@/utils/request'
// 获取所有角色列表
export const getRoleAPI = ({ page, pagesize }) => {
  return axios({
    url: '/sys/role',
    params: {
      page,
      pagesize
    }
  })
}
// 根据id查询企业
export const getCompanyInfoAPI = (companyId) => {
  return axios({
    url: `/company/${companyId}`
  })
}
// 添加角色
export const addRoleAPI = (data) => {
  return axios({
    url: '/sys/role',
    method: 'POST',
    // data: data // 2对key/value
    data // 2对key/value name/description
  })
}
// 根据ID获取角色详情
export const getRoleDetalilAPI = (roleId) => {
  return axios({
    url: `/sys/role/${roleId}`
  })
}
// 根据ID更新角色
export const updateRoleAPI = (roleObj) => {
  return axios({
    url: `/sys/role/${roleObj.id}`,
    method: 'PUT',
    data: roleObj // 5对key/value
  })
}
// 根据ID删除角色
export const deleteRoleAPI = (roleId) => {
  return axios({
    url: `/sys/role/${roleId}`,
    method: 'DELETE'
  })
}

/**
 *给角色分配权限
 * @param {*} data 2对key/value (id/permIds)
 * @returns
 */
export const assignPremAPI = (data) => {
  return axios({
    url: '/sys/role/assignPrem',
    method: 'PUT',
    data
  })
}
